<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "article_recommend".
 *
 * @property string $aid
 * @property string $uid
 */
class ArticleRecommend extends \yii\db\ActiveRecord {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'article_recommend';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['aid', 'uid'], 'required'],
            [['aid', 'uid'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'aid' => '文章ID',
            'uid' => '用户ID',
        ];
    }
    
    public function check($aid) {
        $uid = Yii::$app->user->identity->id;
        $result = ArticleRecommend::findOne(['uid' => $uid, 'aid' => $aid]);
        return $this->render('/widgets/recommend', ['result' => $result, 'aid' => $aid]);
    }

}
